<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="robot" content="index,follow">
<title>Module gsv - gtk-server interface - Forth Foundation Library</title>
</head>
<body>
<h2>gsv - gtk-server interface</h2>
<h3>Module Description</h3>
<p>The gsv module implements an interface to the gtk-server. This server
makes it possible for an ANSish forth engine to show a gtk GUI. Due to the
fact that using this module requires an external tool, this module has an
environmental dependency. See [GTKserver] for how to use this module.
</p>
<h3>Module Words</h3>
<dl>
</dl>
<h4>Low level, overrulable gtk-server connection words</h4>
<dl>
<dt><a name="word1"><b>gsv+connect</b>	( c-addr u -- ior )</dt>
<dd>Connect to the gtk-server via a fifo c-addr u</dd>
<dt><a name="word2"><b>gsv+call</b>	( c-addr1 u1 -- c-addr2 u2 )</dt>
<dd>Call the gtk-server with command c-addr1 u1, resulting in response c-addr2 u2</dd>
<dt><a name="word3"><b>gsv+disconnect</b>	( -- ior )</dt>
<dd>Disconnect from the gtk-server, the gtk-server is *NOT* closed</dd>
</dl>
<h4>gtk-server connection words</h4>
<dl>
<dt><a name="word4"><b>gsv+open</b>	( c-addr1 u1 c-addr2 u2 -- ior )</dt>
<dd>Open the connection to the gtk-server by reading the configuration file c-addr1 u1 and connecting to c-addr2 u2</dd>
<dt><a name="word5"><b>gsv+close</b>	( -- ior )</dt>
<dd>Close the connection to the gtk-server, the gtk-server is *NOT* closed</dd>
</dl>
<h4>gtk-server event words</h4>
<dl>
<dt><a name="word6"><b>gsv+server-connect</b>	( n1 c-addr1 u1 n2 -- c-addr2 u2 )</dt>
<dd>Call gtk_server_connect with widgetid n2, signal c-addr1 u1 and description n2, returning the result c-addr2 u2</dd>
<dt><a name="word7"><b>gsv+server-connect-after</b>	( n1 c-addr1 u1 n2 -- c-addr2 u2 )</dt>
<dd>Call gtk_server_connect_after with widgetid n2, signal c-addr1 u1 and description n2, returning the result c-addr2 u2</dd>
</dl>
<h3>Examples</h3>
<pre>
include ffl/gsv.fs

\ Open the connection to the gtk-server and load all definitions from the gtk-server.cfg file

s" gtk-server.cfg" s" ffl-fifo" gsv+open 0= [IF]


  : event&gt;widget   ( c-addr u -- n = Convert the event string to a widget id )
    0. 2swap &gt;number 2drop d&gt;s
  ;


  0 value window                \ the event widgets
  0 value exit-button
  

  : gsv-example
    gtk_init                    \ Initialise toolkit
                                \ Create toplevel window 
    GTK_WINDOW_TOPLEVEL gtk_window_new to window
    
    s" This is a title" window gtk_window_set_title
    
                                \ Layout the widgets with a table
    1 30 30 gtk_table_new &gt;r
    
    r@ window gtk_container_add
    
                                \ Add a label to the window
    s" Hello world" gtk_label_new &gt;r
    
    7 3 29 1 r@ r'@ gtk_table_attach_defaults
    
    r&gt; gtk_widget_show
    
                                \ Add the exit button to the window
    s" Exit" gtk_button_new_with_label to exit-button   
    
    27 23 28 20 exit-button r@ gtk_table_attach_defaults

    exit-button gtk_widget_show
    
    r&gt;          gtk_widget_show   \ Table
    
    window      gtk_widget_show   \ Window
    
                                  \ Main loop
    BEGIN
      s" WAIT" gtk_server_callback
      event&gt;widget CASE
        window      OF true ENDOF
        exit-button OF true ENDOF
        false swap
      ENDCASE
    UNTIL
    
    0 gtk_exit
  ;

  gsv-example
  
  gsv+close drop
    
[ELSE]
  .( No gtk-server fifo, is the gtk-server running ? ) cr
[THEN]


\ ==============================================================================
</pre>
<hr>
<div align="center">generated 24-Jul-2010 by <b>ofcfrth-0.10.0</b></div>
</body>
</html>
